package org.example.leetCode;

import java.util.Arrays;

/**
 * @Author Qinkai
 * @Description TODO $
 * @Date $ 2021-09-16$
 * @Param $
 * @return $
 **/
public class CheckPermutation {
    public boolean checkPermutation(String s1, String s2) {
        char[] chars1 = s1.toCharArray();
        char[] chars2 = s2.toCharArray();
        if (chars1.length != chars2.length) {
            return false;
        }
        Arrays.sort(chars1);
        Arrays.sort(chars2);
        for (int i = 0; i < chars1.length; i ++) {
            if (chars1[i] != chars2[i]) {
                return false;
            }
        }
        return true;
    }
}
